#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define ASCII_LOW 32
#define ASCII_HIGH 125
#define LCASE_LOW 97
#define LCASE_HIGH 122

char inputChar()
{
	int range;
	range = (ASCII_HIGH - ASCII_LOW) + 1;
	return rand() % range + ASCII_LOW;
}

char *inputString()
{
	int i, range;
	static char s[6];
	for(i = 0; i < 5; i++){
		range = (LCASE_HIGH - LCASE_LOW) + 1;
		s[i] = rand() % range + LCASE_LOW;
	}
	s[5] = '\0';

	return s;
}

void testme()
{
	int tcCount = 0;
	char *s;
	char c;
	int state = 0;
	while (1)
	{
		tcCount++;
		c = inputChar();
		s = inputString();
		//printf("Iteration %d: c = %c, s = %s, state = %d\n", tcCount, c, s, state);

		if (c == '[' && state == 0) state = 1;
			if (c == '(' && state == 1) state = 2;
				if (c == '{' && state == 2) state = 3;
				if (c == ' '&& state == 3) state = 4;
				if (c == 'a' && state == 4) state = 5;
				if (c == 'x' && state == 5) state = 6;
				if (c == '}' && state == 6) state = 7;
				if (c == ')' && state == 7) state = 8;
				if (c == ']' && state == 8) state = 9;
				if (s[0] == 'r' && s[1] == 'e'
				 && s[2] == 's' && s[3] == 'e'
				 && s[4] == 't' && s[5] == '\0'
				 && state == 9)
				{
					printf("Iteration %d: c = %c, s = %s, state = %d\n", tcCount, c, s, state);
					printf("error ");

					exit(200);
				}
			}
		}


		int main(int argc, char *argv[])
		{
			srand(time(NULL));
			testme();
			return 0;
		}
